package com.lqzs.businessmanager.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.lqzs.businessmanager.bean.ReplyInfo

@Dao
interface ReplyDao {

    @Insert
    suspend fun insert(info: ReplyInfo)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertOrUpdate(info: ReplyInfo)

    @Delete
    suspend fun delete(info: ReplyInfo)

    @Query("DELETE FROM reply_table WHERE id=:id")
    suspend fun delete(id: String)

    @Query("DELETE FROM reply_table WHERE review_id=:reviewId")
    suspend fun deleteByReviewId(reviewId:String)

    @Update
    suspend fun update(info: ReplyInfo)

    @Query("UPDATE reply_table SET reply_content=:replayContent WHERE id=:id")
    suspend fun updateReplayContentById(id: String, replayContent:String)

    @Query("SELECT * FROM reply_table WHERE platform_name=:platformName AND branch_id=:branchId")
    suspend fun getAll(platformName: String, branchId: Int): MutableList<ReplyInfo>

    @Query("SELECT * FROM reply_table")
    suspend fun getAll(): MutableList<ReplyInfo>

    @Query("SELECT * FROM reply_table WHERE id =:id")
    suspend fun query(id: String): ReplyInfo?

    @Query("SELECT * FROM reply_table WHERE review_id = :reviewId")
    suspend fun queryForId(reviewId: String): ReplyInfo

    @Query("SELECT * FROM reply_table WHERE state = 0 OR state=3")
    suspend fun queryNoUpload(): MutableList<ReplyInfo>

}